
var _ = require('lodash');  
var nodemailer = require('nodemailer');

var config = {
    host: 'smtp.aliyun.com',
    port: 465,
    secureConnection: true, // 使用 SSL
    auth: {
        user: 'dolov520@aliyun.com',
        pass: 'Dolov2109180918'
    }
};
    
var transporter = nodemailer.createTransport(config);

var defaultMail = {
    from: 'dolov520@aliyun.com',
    text: '',
};

module.exports = function(mail){
    // 应用默认配置
    mail = _.merge({}, defaultMail, mail);
    
    // 发送邮件
    transporter.sendMail(mail,(error, info) => {
        if(error) return console.log(error);
        console.log('mail sent:', info.response);
    });
};